/*
struct TreeNode {
    int val;
    struct TreeNode *left;
    struct TreeNode *right;
    TreeNode(int x) :
            val(x), left(NULL), right(NULL) {
    }
};*/

class TreeToSequence {
public:
    string toSequence(TreeNode* root) {
        // write code here
        string str ="";
        if(root != NULL){
            str += "(";
            str += toSequence(root->left);
            str += toSequence(root->right);
            str+= ")";
        }
        return str;
    }
};
